<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<jsp:include page="/includes/top.jsp"></jsp:include>
<div class="page-header">
	<h1></h1>
</div>
<!-- /.page-header -->
<div class="row">
	<div class="col-xs-12">
		<div class="col-sm-6">
			<div class="row">
				<div
					class="col-xs-11 label label-lg label-info arrowed-in arrowed-right">
					<b>详细信息</b>
				</div>
			</div>
			<div class="row">
				<ul class="list-unstyled spaced" id="divul">
					<li><i class="icon-caret-right blue"></i>公司
						:&nbsp;&nbsp;&nbsp;<b class="c1"></b></li>
					<li><i class="icon-caret-right blue"></i>所有者:&nbsp;&nbsp;&nbsp;<b
						class="c2"></b></li>
					<li><i class="icon-caret-right blue"></i>电子邮件:&nbsp;&nbsp;&nbsp;<b
						class="c3"></b></li>
					<li><i class="icon-caret-right blue"></i>电话:&nbsp;&nbsp;&nbsp;<b
						class="c4"></b></li>
					<li><i class="icon-caret-right blue"></i>固定电话:&nbsp;&nbsp;&nbsp;<b
						class="c5"></b></li>
					<li><i class="icon-caret-right blue"></i>传真:&nbsp;&nbsp;&nbsp;<b
						class="c6"></b></li>
					<li><i class="icon-caret-right blue"></i>地址:&nbsp;&nbsp;&nbsp;<b
						class="c7"></b></li>

				</ul>
			</div>
		</div>
		<!-- /span -->
		<div class="col-sm-6">
			<div class="row">
				<div
					class="col-xs-11 label label-lg label-success arrowed-in arrowed-right">
					<b>描述</b>
				</div>
			</div>
			<div>
				<ul class="list-unstyled spaced">
					<li><i class="icon-caret-right blue"></i><b class="c7"></b></li>
				</ul>
			</div>
		</div>
		<!-- /span -->
	</div>
</div>
<div class="row">
	<div class="col-xs-12">
		<ul class="nav nav-tabs" id="myTab">
			<li class="active"><a href="#tabs-0" data-toggle="tab" data-id="0">活跃项目</a></li>
			<li><a href="#tabs-1" data-toggle="tab" data-id="1">存档项目</a></li>
			<li><a href="#tabs-2" data-toggle="tab" data-id="2">部门</a></li>
		</ul>
		<div class="tab-content">
			<div id="tabs-0" class="tab-pane fade in active">
				<div class="table-responsive">
					<table id="gb-1"
						class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th style="width:2%"><input type="checkbox"
									class="checkAll ace"><span class="lbl"></span></th>
								<th style="width:20%">完成情况</th>
								<th style="width:12%">项目名称</th>
								<th>项目负责人</th>
								<th>主导部门</th>
								<th>开始时间</th>
								<th>预计完成时间</th>
								<th>目标预算</th>
								<th>实际支出</th>
								<th>项目类别</th>
								<th>优先级</th>
								<th>状态</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
			<div id="tabs-1" class="tab-pane fade">
				<div class="table-responsive">
					<table id="gb-2"
						class="table table-striped table-bordered table-hover"
						style="width:100%">
						<thead>
							<tr>
								<th style="width:2%"><input type="checkbox"
									class="checkAll ace"><span class="lbl"></span></th>
								<th style="width:20%">完成情况</th>
								<th style="width:12%">项目名称</th>
								<th>项目负责人</th>
								<th>主导部门</th>
								<th>开始时间</th>
								<th>预计完成时间</th>
								<th>目标预算</th>
								<th>实际支出</th>
								<th>项目类别</th>
								<th>优先级</th>
								<th>状态</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
			<div id="tabs-2" class="tab-pane fade">
				<div class="table-responsive">
					<table id="gb-3"
						class="table table-striped table-bordered table-hover"
						style="width:100%">
						<thead>
							<tr>
								<th style="width:15px"><input type="checkbox" 
									class="checkAll ace"><span class="lbl"></span></th>
								<th>部门名称</th>
							</tr>
						</thead>
					</table>
				</div>
			</div>
		</div>
	</div>
</div>

<jsp:include page="/includes/bottom.jsp"></jsp:include>

<Script type="text/javascript">
	$("document").ready(function(){
		$("#myTab a").click(function (e) { 
			setCookie("detailtab",$(this).attr("data-id"));
        });
		var num = getCookie("detailtab");
		$("#myTab li:eq("+num+") a").tab("show");
		//checkbox全选
	    $(".checkAll").on("click", function () {
	        var num = getCookie("detailtab");
	        num = num == "" ? 0 : num;
	        if ($(this).prop("checked")) {
	            $("#tabs-"+num+" input[name='checkList']").prop("checked", true);
	        } else {
	            $("#tabs-"+num+" input[name='checkList']").prop("checked", false);
	        }
	    }); 
	});
	
	var cid = getQueryString("id");
	
	$.ajax({
		type : "post",
		url : "getcompany",
		data : {'company.companyId' : cid},
		dataType : "json",
		success : function(data) {
			if (typeof (data) == "object") {
				$(".c1").html(data.companyName);
				$(".c2").html(data.companyPerson);
				$(".c3").html(data.email);
				$(".c4").html(data.phone);
				$(".c5").html(data.telephone);
				$(".c6").html(data.address);
				$(".c7").html(data.describes);
			}
		}
	});
	
	var col2 = [	{
						"data" : "projectId",
						"fnCreatedCell" : function(nTd, sData, oData, iRow, iCol) {
							$(nTd).html("<input type='checkbox' name='checkList' value='" + sData + "' class='ace'><span class='lbl'></span>");
						}
					},
					{	
						"data" : "projectPercentComplete",
						"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
						       $(nTd).html("<div class='progress progress-striped'> "+
						       		"<div class='progress-bar progress-bar-success' role='progressbar' "+
						       		"aria-valuenow='"+oData.projectPercentComplete+"' aria-valuemin='0' aria-valuemax='100' style='width: "+oData.projectPercentComplete+"%;'>"+
						   			"<span >"+oData.projectPercentComplete+"%</span> </div></div>");
						 }
					},
					{
						"data": "projectName"
					},
					{"data" : "userinfoTruename"},
					{"data" : "projectDepartmentName"},
					{"data" : "projectStartDate"},
					{"data" : "projectEndDate"},
					{"data" : "projectTargetBudget"},
					{"data" : "projectActualBudget"},
					{"data" : "projectTypeName"},
					{"data" : "projectPriorityName"},
					{"data" : "projectStatusName"}];
	
	//参数说明：id,url,data,column,length			
	tableload("gb-1","projectslist",{'cid':cid,'proComp':'0'},col2,8);
	//参数说明：id,url,data,column,length			
	tableload("gb-2","projectslist",{'cid':cid,'proComp':'1'},col2,8);
	
	var col3 = [
		{
			"data" : "departmentId",
			"fnCreatedCell" : function(nTd, sData, oData, iRow, iCol) {
				$(nTd).html("<input type='checkbox' name='checkList' value='" + sData + "' class='ace'><span class='lbl'></span>");
			}
		}, 
		{"data" : "departmentName"}];
	//参数说明：id,url,data,column,length			
	tableload("gb-3","departid",{cid : cid},col3,8);

	$("#tabs-0 .toolbar").html("");
	$("#tabs-1 .toolbar").html("");
	
	function getSelected(){
		var str = '';
		var num = getCookie("detailtab");
		num = num == "" ? 0 : num;
	    $("#tabs-"+num+" input[name='checkList']:checked").each(function () {
	        str += $(this).val();
	        str += ",";
	    });
	    str = str.substr(0, str.length - 1);
	    return str;
	}
	function _addFun() {
		window.open("departform?m="+mid+"&cid="+cid,"_self");
	}
	function _editFun(){
		var str = getSelected();
	    if (str != '' && str.indexOf(",") < 0) {
	        window.open("departform?m="+mid+"&cid="+cid+"&department.departmentId="+str,"_self");
	    } else {
	        alert("请选择一条记录操作");
	    }
	}
	function _delFun(){
		var str = getSelected();
	    if (str != '' && str.indexOf(",") < 0) {
			if (confirm("确定要删除数据吗？")) {
				$.ajax({
					type : "post",
					url : "deldepart",
					data : {'department.departmentId' : str	},
					success : function(data) {
						showDelMessage(data);
						window.open("Company/companyDetailed.jsp?m="+ mid + "&id=" + cid, "_self");
					}
				});
			}
		} else {
			alert("请选择一条记录操作");
		}
	}
</Script>
